﻿using Heroius.Files.CSV;
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Windows.Data;

namespace IEPI.BIATranscribe
{
    public class CollectionConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return new ObservableCollection<StringShell>(CsvHelper.ReadLine(value.ToString()).Select(str => new StringShell(str)));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return CsvHelper.WriteLine((value as ObservableCollection<StringShell>).Select(shell => shell.Text));
        }
    }

    public class StringShell
    {
        public StringShell(string str)
        {
            Text = str;
        }
        public string Text { get; set; }
    }
}
